using UnityEngine;
using System.Collections;
using System.Collections.Generic;

[AddComponentMenu("TagMachine/Entity/Trail")]
public class EntityTrail : MonoBehaviour
{
	public float RemainingTime 		= 2.0f;

	public Fugitive Parent 			{ get; private set; }

	private Timer m_GameStartTimer 	= null;

	public void Setup( Fugitive _Parent, Color _Color, float _RemainingTime = -1.0f )
	{
		Parent 							= _Parent;

		m_GameStartTimer 				= gameObject.AddComponent< Timer >();
		m_GameStartTimer.DestroyOnEnd 	= false;
		m_GameStartTimer.RestartTimes	= 1;
		m_GameStartTimer.Duration 		= _RemainingTime > 0.0f ? _RemainingTime : RemainingTime;
		m_GameStartTimer.TimerCallbackEvent += OnEndTrail;

		renderer.material.color 		= _Color;
	}

	void OnEndTrail()
	{
		Destroy( gameObject );
	}
}

